package com.threadpool;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author xuejingjing
 * @className ThreadTest
 * @description
 * 时间:21677
 * 大小100000
 * @date 2022/11/13/013 1:16
 */
public class ThreadTest {
    public static void main(String[] args) throws InterruptedException {
        long start = System.currentTimeMillis();
        final Random random = new Random();
        final List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 100000; i++) {
            // 线程执行任务
            Thread thread = new Thread(() -> list.add(random.nextInt()));
            thread.start();
            // 不加会有问题
            thread.join();
        }
        System.out.println("时间:"+(System.currentTimeMillis()-start));
        System.out.println("大小"+list.size());
    }
}
